<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>上海市质监局-产品伤害和缺陷信息监测系统</title>

<link rel="stylesheet" type="text/css"
	href="js/ext4/resources/css/ext-all.css" />
<link rel="stylesheet" type="text/css" href="css/login.css" />
<script type="text/javascript" src="js/ext4/ext-all.js"></script>
<script type="text/javascript" src="js/ext4/locale/ext-lang-zh_CN.js"></script>
<script type="text/javascript" src="js/common/jquery.min.js"></script>
<script type="text/javascript" src="js/common/json2.js"></script>
<script type="text/javascript">
	function validate() {
		var username = document.getElementById("username").value;
		var password = document.getElementById("password").value;
		var securityCode = document.getElementById("securityCode").value;
		var msg = document.getElementById("msg");
		//var username=formObj.username.value;
		//var password=formObj.password.value;
		//var securityCode=formObj.securityCode.value;
		if (username && password) {
			if (securityCode) {
				Ext.Ajax.request({
					url : 'userAction!load.action?user.username=' + username
							+ '&user.password=' + password + '&securityCode='
							+ securityCode,
					success : function(response) {
						var res = response.responseText;
						res = JSON.parse(res);
						res = res.hashMap;
						if (res.security == true) {
							if (res.user && res.user.id) {
								//	document.forms[0].submit();

								Ext.util.Cookies.set('currentUser', username);//用户名
								Ext.util.Cookies.set('currentName',
										res.user.name);//姓名
								location.href = 'index.html';
							} else {
								msg.innerHTML = '用户名或密码错误！！';
							}
						} else {
							msg.innerHTML = '验证码错误！！';
						}
					}
				});
			} else {
				msg.innerHTML = '请输入验证码！';
			}
		} else {
			msg.innerHTML = '请输入用户名和密码！';
		}
	};
	window.onload = function() {
		var verifyObj = document.getElementById("Verify");
		verifyObj.onclick = function() {
			this.src = "securityCodeImageAction.action?timestamp="
					+ new Date().getTime();
		};
	};
	$(function() {
		//点击图片更换验证码
		$("#Verify").click(
				function() {
					$(this).attr(
							"src",
							"securityCodeImageAction.action?timestamp="
									+ new Date().getTime());
				});
	});
	document.onkeydown = function() { //网页内按下回车触发
		if (event.keyCode == 13) {
			document.getElementById("sure_btn").click();
			return false;
		}
	}
</script>
</head>
<body>
	<div class="login_tit">
		<img style="width: 60px; height: 63.6px; float: left;"
			src="images/login/logo.png" /> <img style="margin-top: 22px;"
			src="images/login/login_tit1.png" />
	</div>
	<div class="login_main">
		<span id="msg" style="padding-left: 35%; font-size: 14px; color: red;"></span>
		<p>
			<span>用户名</span> <input name="username" id="username" type="text"
				value="" class="input_01" />
		</p>
		<p>
			<span>密&nbsp;&nbsp;&nbsp;码</span> <input name="password"
				id="password" type="password" value="" class="input_01" />
		</p>
		<p>
			<span>验证码</span> <input maxlength="4" type="text" style="width: 124px;"
				name="securityCode" id="securityCode" value="" class="input_01" />
			<span style="width: 10px;"></span><img
				src="securityCodeImageAction.action"
				style="height: 29px; cursor: pointer;" id="Verify" title="看不清，换一张" />
		</p>
		<p>
			<span></span><input id="sure_btn" type="button" onclick="validate();"
				value="" class="input_02" />
		</p>
	</div>
	<div class="cutpic">
		<img src="images/login/cutpic.png" style="width: 120%; height: 120%;" />
	</div>
	<div class="copyright">
		<span>©CopyRight 2014-2015 上海市质量技术监督局</span>
	</div>
	<div class="login_user"></div>
</body>
</html>
